//
//  GxUserAccount.swift
//  microblog
//
//  Created by 记忆不为 on 16/9/24.
//  Copyright © 2016年 记忆不为. All rights reserved.
//

import UIKit

class GxUserAccount: NSObject,NSCoding {
    //用户授权的唯一票据
    var access_token: String?
    //access_token的过期时间,单位秒
    var expires_in: TimeInterval = 0{
        didSet{
            expiresDate = Date(timeIntervalSinceNow: expires_in)
        }
    }
    //用户过期具体时间
    var expiresDate: Date?
    //授权用户的uid
    var uid: String?
    //用户名称
    var screen_name: String?
    //用户头像地址
    var avatar_large: String?
    init(dic:[String : Any]) {
        super.init()
        setValuesForKeys(dic)
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    required init?(coder aDecoder: NSCoder) {
        access_token = aDecoder.decodeObject(forKey: "aceess_token") as? String
        expires_in = aDecoder.decodeDouble(forKey: "expires_in")
        uid = aDecoder.decodeObject(forKey: "uid") as? String
        expiresDate = aDecoder.decodeObject(forKey: "expiresDate") as? Date
        screen_name = aDecoder.decodeObject(forKey: "screen_name") as? String
        avatar_large = aDecoder.decodeObject(forKey: "avatar_large") as? String
    }
    func encode(with aCoder: NSCoder) {
        aCoder.encode(access_token, forKey: "access_token")
        aCoder.encode(expires_in, forKey: "expires_in")
        aCoder.encode(uid, forKey: "uid")
        aCoder.encode(expiresDate, forKey: "expiresDate")
        aCoder.encode(screen_name, forKey: "screen_name")
        aCoder.encode(avatar_large, forKey: "avatar_large")
    }
   
}
